# Create your views here.
from django.shortcuts import render
from .models import Article
from django.core.paginator import Paginator
from app03.utils.pagination import Pagination

# Create your views here.
# 编辑页显示
def edit_article_(request):
    return render(request, 'editArticle_.html')


# 数据列表页显示
def page_list_(request):
    if request.method == 'POST':
        # 获取页面信息
        title = request.POST['title']
        time = request.POST['time']
        desc = request.POST['desc']
        print('页面信息：', title, time, desc)
        # 写入数据库
        a = Article.objects.create(
            title=title, time=time, desc=desc
        )


    # 数据分页
    # 查询数据集
    content = Article.objects.all()
    print(content)
    

    
    page_object = Pagination(request, content,page_size=2)
    # 将page对象传递到模板中
    return render(request, 'list_.html', {'page_string': page_object.html(),'page_obj':page_object.page_queryset})








